<template>
	<div :class="curClassName" :style="curStyle">
		<img v-if="imgUrl" :src="imgUrl" />
		<i v-else :class="imageClass ? imageClass : ''"></i>
	</div>
</template>
<script setup lang="ts">
import { RawItemImageProps } from './rawitem-image';
const props = defineProps(RawItemImageProps);

/**
 * 项名称
 *
 * @memberof RawItemImage
 */
const itemName = computed(() => {
	return props.index || props.index === 0
		? `${props.name}_${props.index}`
		: props.name;
});

/**
 * 当前容器样式
 *
 * @memberof RawItemImage
 */
const curStyle = computed(() => {
	const layoutModel = props.layoutModelDetails[itemName.value];
	if (layoutModel) {
		return layoutModel.getElementStyle();
	}
});

/**
 * 类名
 *
 * @memberof RawItemImage
 */
const curClassName = computed(() => {
	const layoutModel = props.layoutModelDetails[itemName.value];
	if (layoutModel) {
		return `app-rawitem-image ${itemName.value} ${layoutModel.sysCss || ''}`;
	}
});
</script>
